package cn.lin.task.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.lin.task.dao.ITaskDao;
import cn.lin.task.model.Pager;
import cn.lin.task.model.Task;
import cn.lin.task.model.User;

@Service("taskService")
public class TaskService implements ITaskService {

	private ITaskDao taskDao;
	
	public ITaskDao getTaskDao() {
		return taskDao;
	}
	@Resource
	public void setTaskDao(ITaskDao taskDao) {
		this.taskDao = taskDao;
	}

	@Override
	public void add(Task task) {
		// TODO Auto-generated method stub
		taskDao.add(task);
	}

	@Override
	public void delete(int id) {
		// TODO Auto-generated method stub
		taskDao.delete(id);
	}

	@Override
	public void update(Task task) {
		// TODO Auto-generated method stub
		taskDao.update(task);
	}

	@Override
	public Task load(int id) {
		// TODO Auto-generated method stub
		return taskDao.load(id);
	}
	@Override
	public Pager<Task> find() {
		// TODO Auto-generated method stub
		String hql="from Task task";
		return taskDao.find(hql);
	}
	@Override
	public Pager<Task> find(User user) {
		String hql="from Task task where task.user=?";
		return taskDao.find(hql, user);
	}

}
